﻿using Castle.ActiveRecord;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TES.Domain
{
    /// <summary>
    /// 指标
    /// </summary>
    [ActiveRecord("Indicators")]
    public class Indicators : EntityBase
    {
        [Property(NotNull = true, Length = 50)]
        [Required(ErrorMessage = "不能为空")]
        [StringLength(50, ErrorMessage = "不能超过50个字符")]
        [Display(Name = "指标名称")]
        public virtual string IndicatorsName { get; set; }

        [Property(NotNull = true, Length = 53)]
        [Required(ErrorMessage = "不能为空")]
        [StringLength(53, ErrorMessage = "不能超过53个字符")]
        [Display(Name = "权重")]
        public virtual string Weight { get; set; }

        [BelongsTo(Type = typeof(Indicators),
            Column = "ParentID",
            NotNull = false,
            Cascade = CascadeEnum.None,
            Lazy = FetchWhen.OnInvoke)]
        [Display(Name = "父指标")]
        public virtual Indicators Indicator { get; set; }

        [BelongsTo(Type = typeof(Role),
            Column = "RoleID",
            NotNull = false,
            Cascade = CascadeEnum.None,
            Lazy = FetchWhen.OnInvoke)]
        [Display(Name = "角色")]
        public virtual Role Role { get; set; }
    }
}
